

#import "Asteroid.h"
#import "GameManager.h"

@implementation Asteroid

/*
 Vertex x-Range from: -23.678974 to: 23.264721
 Vertex y-Range from: -21.068602 to: 21.969690
 Vertex z-Range from: -20.450109 to: 17.863581
 
 Suggested radius for bounding sphere: 22.032924333333
 */

- (void) additionalSetup {
    type = ASTEROID;    
    Tex *tex = [[GameManager getInstance] getTex: @"asteroid.png" isImage: YES];
    textureID = [tex getTextureID];         
    radius = 22.032924333333;
    
    GLfloat verticesObjData[ ] = { 
        -0.207126, -0.066316, 17.863581, 23.264721, -1.502157, -0.192209, -0.207126, 21.969690, 0.095400, -23.678974, -2.669385, 0.198593, -0.027670, -21.068602, -2.464037, -3.388360, -1.154920, -20.450109, 11.528797, -0.568606, 16.393007, 20.120089, -1.276288, 10.694796, -0.809213, 9.257827, 17.140844, -0.207126, 18.825060, 10.966887, -11.943050, -0.595412, 16.425299, -20.534342, -1.295913, 10.719969, -0.027670, -10.287013, 15.000261, -0.027670, -14.472719, 6.682102, 7.230282, -1.594619, -17.014429, 20.120089, -1.502157, -11.752726, -0.207126, 10.251815, -18.096594, -0.207126, 18.825060, -10.404342, -11.943050, -0.948562, -18.193747, -20.534342, -1.023628, -10.605993, -0.207126, -12.332569, -18.981672, -0.207126, -19.508356, -10.751425, 20.120089, 10.233767, -0.180500, 11.528797, 18.825060, -0.016802, -11.943050, 18.825060, -0.016802, -17.136053, 8.313806, -0.397686, -20.534342, -12.443668, 0.692919, -11.763594, -18.917589, 0.491507, 11.708252, -19.362967, -0.575785, 20.120089, -12.799344, -0.269648, 11.010029, 10.023398, 8.090002, -13.063187, 11.399381, 13.485727, -12.883731, -12.294924, 12.127554, 12.828390, -12.320704, 12.112505, 12.648933, 11.353903, -13.732217, -13.063187, 11.416142, -13.583072, -13.063187, -12.948364, -12.757673, 12.648933, -13.815801, -14.891082, -0.027670, -17.775347, 0.462729, -0.027670, -10.785804, 11.093355, -7.974440, -15.447367, 2.195024, 7.919100, -15.781916, 1.398743, -8.678226, -11.502975, 8.904417, 8.622885, -11.594921, 8.715879, 0.203016, -1.274000, -17.947115, 12.775757, -1.492089, -13.838882, 2.339248, 5.321407, -15.823799, 2.339248, -7.455033, -16.421265, 8.432550, 5.751537, -14.457232, 8.432550, -8.197471, -15.256260, -19.971733, 2.595546, -0.710552, -17.895210, 2.839720, 6.113892, -18.807550, 3.640034, -6.871016, -14.279131, 14.036302, -0.327436, -14.053627, 9.062331, 7.468456, -14.965967, 9.768659, -8.346003, 10.600231, 2.221758, 12.016981, 15.251944, 1.856801, 9.047716, 2.803887, 9.638645, 12.474089, 2.803887, 13.992887, 9.423529, 15.251944, 9.305200, 2.728025, 10.600231, 13.956913, 2.816954, -0.207126, 21.969690, 0.095400, 11.528797, 18.825060, -0.016802, 11.528797, 18.825060, -0.016802, 11.528797, 18.825060, -0.016802, 20.120089, 10.233767, -0.180500, 20.120089, 10.233767, -0.180500, 20.120089, 10.233767, -0.180500, 23.264721, -1.502157, -0.192209, -19.971733, 2.595546, -0.710552, -17.136053, 8.313806, -0.397686, -17.136053, 8.313806, -0.397686, -17.136053, 8.313806, -0.397686, -14.279131, 14.036302, -0.327436, -11.943050, 18.825060, -0.016802, -11.943050, 18.825060, -0.016802, -0.207126, 21.969690, 0.095400, -11.763594, -18.917589, 0.491507, -11.763594, -18.917589, 0.491507, -11.763594, -18.917589, 0.491507, -20.534342, -12.443668, 0.692919, -20.534342, -12.443668, 0.692919, -20.534342, -12.443668, 0.692919, -23.678974, -2.669385, 0.198593, 23.264721, -1.502157, -0.192209, 20.120089, -12.799344, -0.269648, 20.120089, -12.799344, -0.269648, 20.120089, -12.799344, -0.269648, 11.708252, -19.362967, -0.575785, 11.708252, -19.362967, -0.575785, 11.708252, -19.362967, -0.575785, -0.027670, -21.068602, -2.464037, -0.027670, -21.068602, -2.464037, -23.678974, -2.669385, 0.198593, -19.971733, 2.595546, -0.710552, -19.971733, 2.595546, -0.710552, -14.279131, 14.036302, -0.327436, -14.279131, 14.036302, -0.327436, -11.943050, 18.825060, -0.016802
    };    
    
    GLfloat textureCoordsObjData[ ] = { 
        0.511933, 0.499667, 0.000000, 0.753190, 0.915463, 0.000000, 0.054368, 0.673368, 0.000000, 0.376911, 0.032117, 0.000000, 0.951099, 0.414459, 0.000000, 0.484371, 0.416213, 0.000000, 0.596259, 0.660468, 0.000000, 0.674727, 0.798045, 0.000000, 0.365551, 0.557660, 0.000000, 0.221873, 0.618785, 0.000000, 0.443365, 0.331518, 0.000000, 0.400423, 0.184292, 0.000000, 0.669252, 0.429368, 0.000000, 0.765638, 0.383536, 0.000000, 0.503857, 0.572961, 0.000000, 0.521286, 0.787911, 0.000000, 0.294277, 0.472547, 0.000000, 0.167899, 0.471408, 0.000000, 0.471063, 0.289744, 0.000000, 0.444918, 0.159709, 0.000000, 0.668695, 0.449126, 0.000000, 0.821048, 0.415973, 0.000000, 0.523282, 0.987138, 0.000000, 0.277151, 0.915329, 0.000000, 0.007749, 0.456259, 0.000000, 0.138496, 0.176471, 0.000000, 0.560975, 0.017201, 0.000000, 0.781952, 0.165165, 0.000000, 0.945935, 0.519981, 0.000000, 0.910399, 0.745701, 0.000000, 0.418539, 0.775995, 0.000000, 0.206724, 0.393945, 0.000000, 0.615961, 0.234995, 0.000000, 0.784290, 0.594949, 0.000000, 0.300945, 0.669701, 0.000000, 0.250696, 0.287367, 0.000000, 0.649960, 0.224705, 0.000000, 0.729684, 0.635959, 0.000000, 0.843384, 0.348170, 0.000000, 0.709311, 0.409802, 0.000000, 0.753197, 0.247620, 0.000000, 0.874056, 0.478244, 0.000000, 0.663767, 0.283529, 0.000000, 0.792351, 0.519477, 0.000000, 0.490483, 0.469265, 0.000000, 0.508666, 0.655244, 0.000000, 0.386401, 0.509299, 0.000000, 0.592850, 0.493051, 0.000000, 0.386555, 0.600114, 0.000000, 0.611951, 0.582375, 0.000000, 0.248617, 0.090600, 0.000000, 0.278686, 0.201907, 0.000000, 0.341885, 0.134101, 0.000000, 0.067374, 0.326368, 0.000000, 0.185671, 0.305024, 0.000000, 0.244802, 0.205051, 0.000000, 0.541431, 0.703632, 0.000000, 0.581166, 0.799010, 0.000000, 0.370820, 0.658315, 0.000000, 0.304298, 0.689334, 0.000000, 0.462506, 0.876245, 0.000000, 0.344768, 0.858742, 0.000000, 0.049151, 0.482785, 0.000000, 0.111095, 0.697170, 0.000000, 0.111095, 0.697170, 0.000000, 0.111095, 0.697170, 0.000000, 0.264228, 0.932092, 0.000000, 0.264228, 0.932092, 0.000000, 0.264228, 0.932092, 0.000000, 0.543030, 0.948962, 0.000000, 0.342132, 0.062312, 0.000000, 0.233245, 0.116173, 0.000000, 0.233245, 0.116173, 0.000000, 0.233245, 0.116173, 0.000000, 0.131924, 0.203011, 0.000000, 0.076760, 0.286514, 0.000000, 0.076760, 0.286514, 0.000000, 0.049151, 0.482785, 0.000000, 0.864629, 0.131448, 0.000000, 0.864629, 0.131448, 0.000000, 0.864629, 0.131448, 0.000000, 0.706831, 0.027238, 0.000000, 0.706831, 0.027238, 0.000000, 0.706831, 0.027238, 0.000000, 0.468322, -0.010942, 0.000000, 0.543030, 0.948962, 0.000000, 0.816401, 0.859411, 0.000000, 0.816401, 0.859411, 0.000000, 0.816401, 0.859411, 0.000000, 0.962139, 0.651005, 0.000000, 0.962139, 0.651005, 0.000000, 0.962139, 0.651005, 0.000000, 0.936496, 0.297611, 0.000000, 0.936496, 0.297611, 0.000000, 0.468322, -0.010942, 0.000000, 0.342132, 0.062312, 0.000000, 0.342132, 0.062312, 0.000000, 0.131924, 0.203011, 0.000000, 0.131924, 0.203011, 0.000000, 0.076760, 0.286514, 0.000000
    };
    
    GLfloat normalsObjData[ ] = {
        0.003697, -0.091516, 0.995797, 0.960635, -0.009128, 0.277662, 0.000000, 0.960620, 0.277864, -0.952034, 0.153941, 0.264449, -0.027300, -0.982476, -0.184377, 0.100544, 0.032613, -0.994398, 0.431710, 0.228092, 0.872697, 0.751111, 0.159021, 0.640737, 0.182587, 0.391355, 0.901944, 0.184230, 0.749000, 0.636442, -0.345698, -0.066369, 0.935996, -0.848861, 0.075828, 0.523149, -0.009580, -0.713061, 0.701036, 0.003371, -0.839616, 0.543170, 0.303673, 0.030996, -0.952272, 0.763386, 0.008987, -0.645880, 0.094384, 0.352707, -0.930961, -0.000691, 0.853692, -0.520777, -0.469468, -0.007221, -0.882920, -0.876170, 0.048828, -0.479522, 0.043528, -0.377479, -0.924995, -0.051291, -0.900582, -0.431650, 0.543550, 0.483431, 0.686184, 0.498526, 0.536516, 0.680898, -0.593064, 0.747824, 0.298386, -0.857456, 0.432127, 0.279348, -0.737814, -0.535100, 0.411459, -0.038091, -0.775229, 0.630531, 0.074511, -0.775869, 0.626478, 0.751808, -0.536277, 0.383656, 0.549312, 0.545938, 0.632619, -0.608618, 0.503179, 0.613510, -0.267024, -0.698975, 0.663425, 0.290151, -0.697242, 0.655490, 0.501162, 0.458294, -0.734032, -0.584840, 0.546924, -0.599029, -0.546715, -0.590989, -0.593157, 0.482835, -0.480230, -0.732291, 0.019595, -0.744662, 0.667155, -0.022298, -0.938299, 0.345106, 0.139119, -0.747562, 0.649459, -0.115962, -0.745121, 0.656771, 0.200090, -0.917767, 0.343028, -0.182966, -0.931377, 0.314738, 0.436004, 0.037244, -0.899174, 0.337312, 0.028683, -0.940956, 0.388036, -0.005606, -0.921627, 0.366542, 0.064780, -0.928144, 0.265028, 0.029359, -0.963794, 0.283971, 0.046665, -0.957697, -0.822885, 0.528548, 0.208561, -0.820617, 0.554704, 0.137446, -0.878331, 0.457948, -0.137182, -0.897719, 0.391166, 0.202708, -0.920951, 0.375132, 0.105472, -0.863365, 0.479034, -0.158518, 0.503376, 0.643561, 0.576579, 0.400064, 0.658891, 0.637033, 0.596823, 0.482096, 0.641394, 0.644496, 0.375890, 0.665832, 0.491379, 0.530631, 0.690636, 0.555045, 0.470129, 0.686225, 0.246129, 0.928489, -0.278079, 0.246129, 0.928489, -0.278079, 0.372092, 0.827537, -0.420393, 0.668623, 0.674584, -0.312858, 0.668623, 0.674584, -0.312858, 0.813113, 0.408711, -0.414492, 0.934158, 0.250560, -0.254105, 0.934158, 0.250560, -0.254105, -0.890027, 0.446425, -0.092504, -0.890027, 0.446425, -0.092504, -0.853748, 0.501128, -0.141368, -0.882397, 0.442494, -0.159922, -0.882397, 0.442494, -0.159922, -0.372558, 0.827060, -0.420919, -0.246129, 0.928489, -0.278079, -0.246129, 0.928489, -0.278079, -0.220149, -0.959481, -0.175872, -0.382416, -0.855909, -0.348107, -0.572756, -0.766956, -0.289360, -0.572756, -0.766956, -0.289360, -0.798693, -0.423219, -0.427756, -0.900793, -0.305419, -0.308694, -0.900793, -0.305419, -0.308694, 0.932327, -0.257780, -0.253607, 0.932327, -0.257780, -0.253607, 0.826731, -0.401049, -0.394557, 0.600691, -0.757978, -0.254243, 0.600691, -0.757978, -0.254243, 0.291806, -0.898164, -0.328863, 0.170540, -0.967661, -0.185872, 0.066341, -0.662828, 0.745827, -0.023714, -0.664104, 0.747264, -0.820168, 0.550779, -0.154812, -0.820168, 0.550779, -0.154812, -0.904151, 0.415232, -0.100462, -0.870470, 0.461535, -0.171077, -0.881642, 0.440988, -0.168041, -0.881642, 0.440988, -0.168041
    };
    
    GLushort facesObjData[ ] = { 
        0, 6, 8, 56, 57, 30, 56, 30, 58, 58, 30, 59, 7, 1, 22, 57, 60, 30, 30, 60, 61, 30, 61, 59, 9, 23, 2, 0, 8, 10, 8, 9, 31, 8, 31, 10, 10, 31, 11, 9, 2, 24, 9, 24, 31, 54, 53, 25, 54, 25, 51, 51, 25, 50, 0, 10, 12, 10, 11, 32, 10, 32, 12, 39, 42, 13, 11, 3, 26, 11, 26, 32, 32, 26, 27, 42, 40, 13, 13, 40, 38, 0, 12, 6, 39, 13, 43, 12, 33, 6, 6, 33, 7, 13, 38, 41, 13, 41, 43, 33, 28, 29, 33, 29, 7, 7, 29, 1, 44, 46, 14, 16, 17, 34, 46, 48, 14, 14, 48, 45, 17, 62, 63, 17, 64, 34, 34, 65, 66, 34, 67, 15, 15, 68, 69, 5, 18, 16, 18, 19, 35, 18, 35, 16, 16, 35, 17, 52, 70, 71, 52, 72, 55, 55, 73, 74, 35, 75, 17, 17, 76, 77, 5, 20, 18, 20, 21, 36, 20, 36, 18, 18, 36, 19, 21, 4, 78, 21, 79, 36, 36, 80, 81, 36, 82, 19, 19, 83, 84, 44, 14, 47, 14, 45, 49, 14, 49, 47, 20, 37, 21, 15, 85, 86, 15, 87, 37, 37, 88, 89, 37, 90, 21, 21, 91, 4, 12, 32, 42, 42, 39, 12, 32, 27, 40, 40, 42, 32, 27, 92, 38, 38, 40, 27, 33, 12, 39, 39, 43, 33, 38, 28, 41, 28, 38, 93, 28, 33, 43, 43, 41, 28, 44, 5, 16, 16, 46, 44, 16, 34, 48, 48, 46, 16, 34, 15, 45, 45, 48, 34, 44, 20, 5, 20, 44, 47, 15, 37, 49, 49, 45, 15, 49, 20, 47, 20, 49, 37, 51, 31, 54, 31, 51, 11, 31, 24, 53, 53, 54, 31, 50, 11, 51, 11, 50, 3, 35, 19, 52, 52, 55, 35, 19, 94, 95, 96, 52, 19, 97, 35, 55, 35, 98, 99, 8, 6, 56, 56, 58, 8, 6, 7, 57, 57, 56, 6, 9, 8, 58, 58, 59, 9, 57, 22, 60, 22, 57, 7, 22, 23, 61, 61, 60, 22, 61, 9, 59, 9, 61, 23
    };
    
    [self setVertices: verticesObjData
                 size: sizeof(verticesObjData) 
         setTexCoords: textureCoordsObjData
                 size: sizeof(textureCoordsObjData)
           setNormals: normalsObjData
                 size: sizeof(normalsObjData)
             setFaces: facesObjData
                 size: sizeof(facesObjData)];   
}

@end